package com.srp.mapper;
import com.srp.pojo.GetUserInfoReturn;
import com.srp.pojo.UserInformation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {
    @Insert("insert ignore into user  (id,password,phone, avatar_url,name, create_time,update_time)" +
            "values(#{id},#{password},#{phone},#{avatar_url},#{name},#{createTime},#{updateTime})")
   int insert(String id, String password, String phone, String avatar_url,String name ,LocalDateTime createTime,
    LocalDateTime updateTime );
    @Select("select count(primary_id) from user where password=#{password} AND phone=#{phone}" )
    int getCountWherePasswordAndPhone(String password,String phone);
    @Select("select count(primary_id) from user where id=#{id}" )
    int getCountWhereId(String id);
    @Select("select id from user where password=#{password} AND phone=#{phone}" )
    String getIdWherePasswordAndPhone(String password,String phone);
    @Select("select name from user where id=#{id} " )
    String getNameWhereId(String id);
    @Select("select avatar_url from user where id=#{id} " )
    String getURLWhereId(String id);
    @Select("select name,phone,avatar_url from user where  id=#{id}" )
    GetUserInfoReturn getUserInfoWherePasswordAndPhone(String id);

    @Update("update user set name=#{name} where id = #{id}")
    //@Select("select name from user where  id=#{id}" )
    int updateName(String name,String id);
 @Update("update user set avatar_url=#{avatar_url} where id = #{id}")
  //@Select("select name from user where  id=#{id}" )
 int updateURL(String avatar_url,String id);
}
